﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
namespace BISPOS.Report
{
    public class ReportProductGroup
    {
        private BISPOSDataClassesDataContext db = new BISPOSDataClassesDataContext();

        private ProductGroup productGroup;

        public ReportProductGroup(int _id)
        {
            productGroup = db.ProductGroups.FirstOrDefault(x=>x.Id == _id);
        }

        public System.Data.Linq.EntitySet<ReportProduct> ReportProducts
        {
            get
            {
                EntitySet<ReportProduct> reportProducts = new EntitySet<ReportProduct>();
                foreach(var product in db.ProductGroups.FirstOrDefault(x=>x.Id == productGroup.Id).Products)
                {
                    reportProducts.Add(new ReportProduct{
                        BarCode = product.Barcode,
                        Name = product.Name,
                        StockCount = product.StockCount});
                }
                return reportProducts;
            }
        }
        public string Name { get{return productGroup.Name;}  }
        public string Code { get{return productGroup.Code;}  }

    }
}
